package com.taglab.chic.search;

import java.util.Date;

/**
 * @author Markus Kobler
 */
public class Hit {
  
  private String url;

  private String title;

  private String description;

  private Date modified;

  public Hit(String url, String title, String description) {
    this(url, title, description, null);
  }

  public Hit(String url, String title, String description, Date modified) {
    if( url == null ) throw new IllegalArgumentException("url cannot be null");
    this.url = url;
    this.title = title;
    this.description = description;
    this.modified = modified;
  }

  public String getUrl() {
    return url;
  }

  public String getTitle() {
    return title;
  }

  public String getDescription() {
    return description;
  }

  public Date getModified() {
    return modified;
  }

  @Override
  public boolean equals(Object that) {
    if (this == that) return true;
    if (that == null || getClass() != that.getClass()) return false;
    return url.equals(((Hit) that).url);
  }

  @Override
  public int hashCode() {
    return url.hashCode();
  }

  @Override
  public String toString() {
    return "Hit["+url+"]";
  }

  public String toLongString() {
    final StringBuilder sb = new StringBuilder();
    sb.append("Hit");
    sb.append("{url='").append(url).append('\'');
    sb.append(", title='").append(title).append('\'');
    sb.append(", description='").append(description).append('\'');    
    sb.append(", modified=").append(modified);
    sb.append('}');
    return sb.toString();
  }

}
